package aep

import (
	"fmt"
	"log"
	"strings"
)

func print(prefix string, s ...interface{}) {
	w := &IWrite{}
	ss := fmt.Sprintln(append([]interface{}{": "}, s...)...)
	ss = strings.ReplaceAll(ss, string(byte(32)), "")
	ss = strings.ReplaceAll(ss, string(byte(13)), "")
	ss = strings.ReplaceAll(ss, string(byte(10)), "")
	log.New(w, "["+prefix+"] ", log.Ldate|log.Ltime|log.Lmsgprefix).Output(4, ss)
	fmt.Println(w.String())
}

type IWrite struct {
	bs []byte
	s  string
}

func (this *IWrite) String() string {
	return this.s
}

func (this *IWrite) Write(p []byte) (n int, err error) {
	this.bs = p
	this.s = string(p)
	return len(p), nil
}
